package com.trailwalker.javafx.core.entity;


import com.trailwalker.JavaUtils.log.LogUtils;

import java.util.HashMap;
import java.util.Map;

/**
 * @author Trailwalker
 * @create 2021-06-30 11:33
 * @des
 */
public class Bundle {

    private static final String TAG = Bundle.class.getSimpleName();

    private Map<String, String> stringMap = new HashMap<>();
    private Map<String, Boolean> booleanMap = new HashMap<>();
    private Map<String, Integer> integerMap = new HashMap<>();
    private Map<String, Long> longMap = new HashMap<>();
    private Map<String, Float> floatMap = new HashMap<>();
    private Map<String, Double> doubleMap = new HashMap<>();

    public void putString(String key, String value) {
        LogUtils.log(TAG, this.hashCode() + " putString key >> " + key + " value >> " + value);
        stringMap.put(key, value);
    }

    public String getString(String key, String defaultValue) {
        String value = stringMap.get(key);
        if (value != null) {
            return value;
        } else {
            return defaultValue;
        }
    }

    public void putBoolean(String key, boolean value) {
        LogUtils.log(TAG, this.hashCode() + " putBoolean key >> " + key + " value >> " + value);
        booleanMap.put(key, value);
    }

    public boolean getBoolean(String key, boolean defaultValue) {
        Boolean value = booleanMap.get(key);
        if (value != null) {
            return value;
        } else {
            return defaultValue;
        }
    }

    public void putInteger(String key, int value) {
        LogUtils.log(TAG, this.hashCode() + " putInteger key >> " + key + " value >> " + value);
        integerMap.put(key, value);
    }

    public int getInteger(String key, int defaultValue) {
        Integer value = integerMap.get(key);
        if (value != null) {
            return value;
        } else {
            return defaultValue;
        }
    }

    public void putLong(String key, Long value) {
        LogUtils.log(TAG, this.hashCode() + " putLong key >> " + key + " value >> " + value);
        longMap.put(key, value);
    }

    public long getLong(String key, long defaultValue) {
        Long value = longMap.get(key);
        if (value != null) {
            return value;
        } else {
            return defaultValue;
        }
    }

    public void putFloat(String key, float value) {
        LogUtils.log(TAG, this.hashCode() + " putFloat key >> " + key + " value >> " + value);
        floatMap.put(key, value);
    }

    public float getFloat(String key, float defaultValue) {
        Float value = floatMap.get(key);
        if (value != null) {
            return value;
        } else {
            return defaultValue;
        }
    }

    public void putDouble(String key, double value) {
        LogUtils.log(TAG, this.hashCode() + " putDouble key >> " + key + " value >> " + value);
        doubleMap.put(key, value);
    }

    public double getDouble(String key, double defaultValue) {
        Double value = doubleMap.get(key);
        if (value != null) {
            return value;
        } else {
            return defaultValue;
        }
    }

    public Map<String, String> getStringMap() {
        return stringMap;
    }

    public void setStringMap(Map<String, String> stringMap) {
        this.stringMap = stringMap;
    }

    public Map<String, Boolean> getBooleanMap() {
        return booleanMap;
    }

    public void setBooleanMap(Map<String, Boolean> booleanMap) {
        this.booleanMap = booleanMap;
    }

    public Map<String, Integer> getIntegerMap() {
        return integerMap;
    }

    public void setIntegerMap(Map<String, Integer> integerMap) {
        this.integerMap = integerMap;
    }

    public Map<String, Long> getLongMap() {
        return longMap;
    }

    public void setLongMap(Map<String, Long> longMap) {
        this.longMap = longMap;
    }

    public Map<String, Float> getFloatMap() {
        return floatMap;
    }

    public void setFloatMap(Map<String, Float> floatMap) {
        this.floatMap = floatMap;
    }

    public Map<String, Double> getDoubleMap() {
        return doubleMap;
    }

    public void setDoubleMap(Map<String, Double> doubleMap) {
        this.doubleMap = doubleMap;
    }
}
